package com.bz.sunmipay.application;


import android.app.Application;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;

import com.baizhi.baseapp.application.BaseApplication;
import com.baizhi.baseapp.widget.WToast;
import com.bz.sunmipay.payment.PaymentHelp;
import com.sunmi.pay.hardware.aidlv2.emv.EMVOptV2;
import com.sunmi.pay.hardware.aidlv2.pinpad.PinPadOptV2;
import com.sunmi.pay.hardware.aidlv2.readcard.ReadCardOptV2;
import com.sunmi.pay.hardware.aidlv2.security.SecurityOptV2;
import com.sunmi.pay.hardware.aidlv2.system.BasicOptV2;
import com.sunmi.pay.hardware.aidlv2.tax.TaxOptV2;

import org.greenrobot.eventbus.EventBus;

/**
 * application
 * <p/>
 * Created by sunquan on 2015/5/4 0020.
 */
public class MyApplication extends BaseApplication {

    public static BasicOptV2 mBasicOptV2;       // 获取基础操作模块
    public static ReadCardOptV2 mReadCardOptV2; // 获取读卡模块
    public static PinPadOptV2 mPinPadOptV2;     // 获取PinPad操作模块
    public static SecurityOptV2 mSecurityOptV2; // 获取安全操作模块
    public static EMVOptV2 mEMVOptV2;           // 获取EMV操作模块
    public static TaxOptV2 mTaxOptV2;           // 获取税控操作模块

    private ServiceConnection mConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName className, IBinder service) {
            //用绑定方法启动service，就是从这里绑定并得到service，然后就可以操作service了
        }

        @Override
        public void onServiceDisconnected(ComponentName arg0) {
        }
    };

    public static Application getAppContext() {
        return sInstance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        WToast.init(getApplicationContext());
        PaymentHelp.getInstance(this).initWireCard();
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        EventBus.clearCaches();
    }
}
